package com.dundun.pattern.abstractfactory.factory.table;

import com.dundun.pattern.abstractfactory.factory.Item;
import com.dundun.pattern.abstractfactory.factory.Tray;

public class TableTray extends Tray {

    public TableTray(String caption) {
        super(caption);
    }

    @Override
    public String makeHTML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<td>");
        sb.append("<table width='100%' border='1'><tr>");
        sb.append("<td bgcolor='#cccccc' align='center' colspan='").append(tray.size()).append("'><b>");
        sb.append(caption).append("</b></td></tr>\n");
        sb.append("<tr>\n");
        for(Item it : tray) {
            sb.append(it.makeHTML());
        }
        sb.append("</tr></table></td>");
        return sb.toString();
    }
}
